program Two;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
i, n, max, min: integer;
mass: array of integer;
fin: textFile;

begin
  assignFile (fin, 'input.txt');
  reset (fin);
  readln(fin, n);
  setlength (mass, n);
  for i:= 0 to n-1 do
    read(fin, mass[i]);
  min:=mass[0];
  max:=mass[0];
  for i:= 1 to n-1 do
  begin
    if (min>mass[i]) then
      min:=mass[i];
    if (max<mass[i]) then
      max:=mass[i];
  end;
  closeFile (fin);
  writeln(max+min);
  readln;
end.
